<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserInventory extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('user_inventory')) {
            Schema::create('user_inventory', function (Blueprint $table) {
                $table->id();
                $table->unsignedInteger('c_id')->default(0)->comment('品类ID');
                $table->string('c_number')->default('')->comment('品类编号');
                $table->string('type')->default('')->comment('品类类型');
                $table->string('model')->default('')->comment('品类型号');
                $table->string('uom')->default('')->comment('计量单位');
                $table->decimal('sale_price', 15, 2)->default(0)->comment('销售价');
                $table->decimal('out_price', 15, 2)->default(0)->comment('出库价');
                $table->string('description')->default('')->comment('描述');
                $table->integer('inventory')->default(0)->comment('库存数量(入库数)');
                $table->integer('safe_inventory')->default(0)->comment('安全库存');
                $table->integer('disabled_inventory')->default(0)->comment('不可用');
                $table->unsignedInteger('create_user_id')->default(0)->comment('创建人ID');
                $table->integer('create_time')->nullable();
                $table->integer('update_time')->nullable();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_inventory');
    }
}
